package ink.lovejinhu.leetcodeMatch;

/**
 * @author jinhu
 * created 2021-07-18 10:43
 */
public class Solution_5814 {
    /**
     * rungs严格递增
     *
     * @param rungs
     * @param dist
     * @return
     */
    public int addRungs(int[] rungs, int dist) {
        int start = 0;
        int need = 0;
        for (int i = 0; i < rungs.length; i++) {
            if (rungs[i] - start <= dist)   //证明可以到达
            {
                start = rungs[i];
            } else {   //不可以到达
                int temp = (rungs[i] - start) / dist;
                if ((rungs[i] - start) % dist == 0) {
                    need = temp + need - 1;
                } else {
                    need += temp;
                }
                start = rungs[i];
            }
        }
        return need;
    }

    public static void main(String[] args) {
        Solution_5814 solution_5814 = new Solution_5814();
        int[] rungs = {1, 3, 5, 10};
        int dist = 2;
        solution_5814.addRungs(rungs, dist);
        System.out.println(solution_5814.addRungs(rungs, dist));
    }
}
